package com.thd.springboottest.mybatis.service;

import com.thd.springboottest.mybatis.dao.MyUserMapper;
import com.thd.springboottest.mybatis.dao.SpecialTypeMapper;
import com.thd.springboottest.mybatis.entity.MyUser;
import com.thd.springboottest.mybatis.entity.SpecialType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author devil13th
 **/
@Service
public class SpecialTypeServiceImpl implements  SpecialTypeService {
    @Autowired
    private SpecialTypeMapper specialTypeMapper;
    @Override
    public int save(SpecialType data) {return specialTypeMapper.save(data);}
    @Override
    public int update(SpecialType data) {
        return specialTypeMapper.update(data);
    }
    @Override
    public SpecialType queryById(String id) {return specialTypeMapper.queryById(id);}
    @Override
    public List<SpecialType> queryList(SpecialType date) {return specialTypeMapper.queryList(date);}
    @Transactional(propagation = Propagation.REQUIRED)
    public void testNewTransactionException(){
        SpecialType data = this.queryById("1");
        data.setBalance(data.getBalance().add(new BigDecimal(1)));
        this.update(data);
        int a = 1/0;
    }

}
